<!-- 产品检验批次 -->
<template>
  <el-dialog :title="title" :visible.sync="open" width="80%" append-to-body :close-on-click-modal="false" v-dialogDrag>
    <div class="app-container">
      <el-row :gutter="20" style="height: 100%;">
        <el-col :span="20" :xs="24" style="height:100%; overflow: auto;">
          <el-form style="display: flex;align-items: center;margin: 15px 0;" :model="queryParams" ref="queryForm"
            size="mini" label-position="right" :inline="true" label-width="88px">
            <el-form-item style="display: flex;" label="检验批次号" prop="num">
              <el-input v-model="queryParams.no" placeholder="请输入检验批次号" clearable @keyup.enter.native="handleQuery" />
            </el-form-item>
            <el-form-item style="display: flex;" label="检验日期" prop="datetime">
              <el-date-picker v-model="queryParams.datetime" type="daterange" range-separator="至"
                start-placeholder="开始日期" end-placeholder="结束日期">
              </el-date-picker>
            </el-form-item>
            <el-form-item style="display: flex;">
              <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
              <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
            </el-form-item>
          </el-form>
        </el-col>
        <el-col :span="20" :xs="24" style="height:100%; overflow: auto;margin-bottom: 10px;">
          <el-button type="primary" plain icon="el-icon-plus" size="mini" @click="addNum"
            v-hasPermi="['develop:GoodsOrderIn:add']">新增
          </el-button>
        </el-col>
        <el-table border v-loading="loading"  :data="dataList" @selection-change="handleSelectionChange">
          <el-table-column type="selection" align="center" />
          <el-table-column label="检验批次号" align="center" :show-overflow-tooltip="true" prop="batchNumber"  />
          <el-table-column label="检验日期" align="center" :show-overflow-tooltip="true" prop="createTime"  />

          <el-table-column prop="fileList" label="生产厂检测报告" align="center">
            <template slot-scope="scope">
              <file-upload-show :value="scope.row.materialReport"></file-upload-show>
            </template>
          </el-table-column>

          <el-table-column prop="fileList" label="来料检测报告" align="center">
            <template slot-scope="scope">
              <file-upload-show :value="scope.row.productReport"></file-upload-show>
            </template>
          </el-table-column>

          <el-table-column label="操作" align="center" fixed="right" class-name="small-padding fixed-width">
            <template slot-scope="scope">
              <el-button size="mini" type="text" icon="el-icon-edit" @click="onEdit(2)"
                v-hasPermi="['develop:GoodsFundBack:edit']">修改</el-button>
              <el-popconfirm :title="`确认删除当前数据项？`" @confirm="handleDelete(scope.row)" style="margin-left: 10px;">
                <el-button slot="reference" size="mini" type="text" icon="el-icon-delete"
                  v-hasPermi="['develop:GoodsFundBack:remove']">删除</el-button>
              </el-popconfirm>
            </template>
          </el-table-column>
        </el-table>
        <pagination v-show="total>0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize"
          @pagination="getList" />
      </el-row>
    </div>
    <RawMaterialDetectionForm ref="rawMaterialDetectionForm" @ok="getList" />
  </el-dialog>
</template>

<script>
  import RawMaterialDetectionForm from '@/views/develop/factory/setUp/module/RawMaterialDetectionForm'
  import {
    getAction
  } from "@/api/manage";
  import FileUploadShow from "@/components/FileUpload/FileUploadShow.vue";
  export default {
    name: 'RawMaterialList',
    components: {
      FileUploadShow,
      RawMaterialDetectionForm
    },
    data() {
      return {
        title: '检验批次',
        // 选中数组
        ids: [],
        rows: [],
        // 非单个禁用
        single: true,
        // 非多个禁用
        multiple: true,
        // 遮罩层
        loading: true,
        // 是否显示弹出层
        open: false,
        // 总条数
        total: 0,
        // 研发经费表格数据
        dataList: [],
        activeName: '1',
        // 查询参数
        queryParams: {
          pageNum: 1,
          pageSize: 10,
          goodsId: null,
          type: '',
          num: '',
          no: '',
          datetime: ''
        },
        url: {
          materialMainTest: "/factoryMaterialMain/factoryMaterialMain/list"
        },
        numList: []
      }
    },
    created() {

    },
    methods: {
      showChuruku(order) {
        this.rows = order;
        this.queryParams.goodsId = order.goodsId;
        this.queryParams.goodsSaleId = order.goodsSaleId;
        this.getList();
        this.open = true;
      },
      //新增原材料检测
      addNum() {
        this.$refs.rawMaterialDetectionForm.handleAdd();
      },
      //编辑原材料编号名称
      onEdit() {
        var obj = {}
        this.$refs.rawMaterialDetectionForm.handleUpdate(obj);
      },
      /** 搜索按钮操作 */
      handleQuery() {
        this.queryParams.pageNum = 1;
        this.getList();
      },
      /** 重置按钮操作 */
      resetQuery() {
        this.resetForm("queryForm");
        this.handleQuery();
      },
      /** 删除按钮操作 */
      handleDelete(e) {
        this.getList();
        this.$modal.msgSuccess("删除成功");
      },
      // 多选框选中数据
      handleSelectionChange(selection) {
        this.ids = selection.map(item => item.id)
        this.single = selection.length !== 1
        this.multiple = !selection.length
      },
      /** 查询原材料列表 */
      getList() {
        this.loading = true;
        getAction(this.url.materialMainTest, this.queryParams).then(response => {
          this.dataList = response.rows;
          this.total = response.total;
          this.loading = false;
        });

      },
    }
  }
</script>

<style scoped lang="scss">
  ::v-deep .el-form-item--medium,
  ::v-deep .el-form-item__content {
    width: 100%;
  }

  ::v-deep .el-collapse-item__wrap,
  ::v-deep .el-collapse,
  ::v-deep .el-collapse-item__header {
    border: none;
  }

  ::v-deep .el-date-editor--daterange.el-input__inner {
    width: 228px;
  }

  ::v-deep .el-form-item__label {
    font-size: 12px;
    font-weight: 500;
    padding: 0 5px 0 0;
  }

  ::v-deep .el-form-item {
    margin-bottom: 0;
  }

  .jculbox {
    display: flex;
    flex-wrap: wrap;
    padding: 0 10px;
  }

  .jclibox {
    display: flex;
    // align-items: center;
    width: 32%;
    margin-top: 15px;
  }

  .jclihcss {
    font-size: 12px;
    color: #909399;
    margin-right: 10px;
  }

  .jclitcss {
    font-size: 12px;
    color: #333;
  }

  .hbox {
    display: flex;
    align-items: center;
  }

  .hboxhcss {
    font-size: 16px;
    color: #333;
    font-weight: 600;
  }

  .hboxxian {
    width: 5px;
    height: 18px;
    background: #1890ff;
    margin-right: 5px;
    border-radius: 2px;
  }

  .boxcss {
    background: #fff;
    padding: 10px;
    border-radius: 5px;
    margin-right: 15px;
    height: 100%;
  }

  .martcss {
    margin-top: 15px;
  }

  .ulbox {
    height: calc(100% - 65px);
    overflow-y: scroll;
    margin-top: 15px;
  }

  .libox {
    color: #333;
    background: #fff;
    border-color: #fff;
    padding: 10px 15px;
    border-radius: 5px;
    font-size: 12px;
  }

  .libox1 {
    color: #1890ff;
    background: #e8f4ff;
    border-color: #a3d3ff;
    padding: 10px 15px;
    border-radius: 5px;
    font-size: 12px;
    font-weight: 500;
  }

  .libox2 {
    background: #fff;
    border-color: #fff;
    padding: 10px 15px;
    border-radius: 5px;
    border: 1px solid #90939950;
    margin-bottom: 10px;
  }

  .libox3 {
    background: #e8f4ff;
    border-color: #a3d3ff;
    border: 1px solid #1890ff;
    padding: 10px 15px;
    border-radius: 5px;
    margin-bottom: 10px;
  }

  .topbox {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 15px;
  }

  .topboxhbox {
    display: flex;
    align-items: center;
    font-size: 12px;
    color: #909399;
  }

  .hcss {
    font-size: 12px;
    color: #333;
  }

  .hcss1 {
    font-size: 12px;
    font-weight: 500;
    color: #1890ff;
  }
</style>
